package org.casper.outofmemory;

public class TestVMStack {

	private int i = 1;

	public void add() {
		i++;
		add();// 递归调用
	}

	/**
	 * 演示异常:java.lang.StackOverflowError 执行参数: -Xss108k
	 */
	public static void main(String[] args) {
		TestVMStack testVMStack = new TestVMStack();
		try {
			testVMStack.add();
		} catch (Throwable e) {
			e.printStackTrace();
			System.err.println("当前栈深度: " + testVMStack.i);
		}

	}

}
